<?php
	 echo $this->Html->css('jquery.multiselect');
	 echo $this->Html->script('jquery.multiselect');
?>
<script>
<!--

$(function() {
	$("#kenh_id").multiselect({
		   selectedText: "đã chọn # trong # Kênh",
		   checkAllText: 'Chọn Tất cả',
			uncheckAllText: 'Bỏ chọn tất cả',
		   noneSelectedText: '-- Tất cả --'
		});
	$("#nhanvien_id").multiselect({
		   selectedText: "đã chọn # trong # Nhân Viên",
		   checkAllText: 'Chọn Tất cả',
			uncheckAllText: 'Bỏ chọn tất cả',
		   noneSelectedText: '-- Tất cả --'
		});
});
//-->
</script>
<div class="index">
<h2>Báo cáo các công tác tại điểm bán</h2>
<?php echo $form->create('Hinhanhdb');?>

<?php
$thangs = array(1=>1,2=>2,3=>3,4=>4,5=>5,6=>6,7=>7,8=>8,9=>9,10=>10,11=>11,12=>12,);
if(count($donvis)>1)
	$option =  array('id'=>'donvi_id','label'=>'Đơn vị','type'=>'select','options'=>$donvis,'empty'=>'--Tất Cả--');
else
	$option =  array('id'=>'donvi_id','label'=>'Đơn vị','type'=>'select','options'=>$donvis);

?>
<table>
	<tr>
	    <td><?php echo  $form->input('donvi_id',$option);?></td>
	    <td>
	    	<div id="nhanvien">
	    		<?php echo  $form->input('nhanvien_id',array('id'=>'nhanvien_id','label'=>'Nhân viên','multiple'=>'multiple','options'=>$nhanviens,'style'=>'width:100px;'));?>
	    	</div>
	    </td>
	    <td>
	    	<div id="kenh">
				<?php echo $form->input('kenh',array('id'=>'kenh_id','label'=>'Kênh','multiple'=>'multiple','options'=>$kenhs,'style'=>'width:100px;'));?>
			</div>
	    </td>

  	</tr>
  	
  	<tr>
    	<td><?php echo  $form->input('nam',array('id'=>'nam','label'=>'Năm','type'=>'select','options'=>$nams));?></td>
    	<td><?php echo  $form->input('thang',array('id'=>'thang','label'=>'Tháng','type'=>'select','options'=>$thangs));?> </td>
  	</tr>
</table>
<?php echo $js->submit(' Thực Hiện ',array('update'=>'#kq',
    												'url'=>array('controller'=>'hinhanhdbs','action'=>'laykq')));?>

<div id='kq'>
</div>

<?php

$this->Js->get('#donvi_id')->event('change',
							$this->Js->request(array('controller' => 'hinhanhdbs', 'action' => 'laynv'),
							array('update' =>'#nhanvien','async' => true,
							'dataExpression' => true,'method' => 'post',
							'data' => $js->serializeForm(array('isForm' => false, 'inline' => true)))));

$this->Js->get('#donvi_id')->event('change',
								$this->Js->request(array('controller' => 'kqbanhangs', 'action' => 'emptykq'),
								array('update' => '#kq','async' => true,
								'dataExpression' => true,'method' => 'post',
								'data' => $js->serializeForm(array('isForm' => false, 'inline' => true)))));
$this->Js->get('#donvi_id')->event('change',
								$this->Js->request(array('controller' => 'hinhanhdbs', 'action' => 'laykenh'),
								array('update' => '#kenh','async' => true,
								'dataExpression' => true,'method' => 'post',
								'data' => $js->serializeForm(array('isForm' => false, 'inline' => true)))));
								
							
$this->Js->get('#nhanvien')->event('change',
							$this->Js->request(array('controller' => 'hinhanhdbs', 'action' => 'laykenh'),
							array('update' =>'#kenh','async' => true,
							'dataExpression' => true,'method' => 'post',
							'data' => $js->serializeForm(array('isForm' => false, 'inline' => true)))));
							
?>
</div>